package com.ruoyi.web.controller.information;

import com.lx.information.domain.InformationImportRecord;
import com.lx.information.domain.vo.InformationImportRecordVO;
import com.lx.information.service.IInformationImportRecordService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.service.InformationService;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 信息导入记录Controller
 *
 * @author lx
 * @date 2023-04-03
 */
@RestController
@RequestMapping("/information/record")
public class ImportRecordController extends BaseController {
    @Autowired
    private ISysUserService userService;
    @Autowired
    private IInformationImportRecordService informationImportRecordService;

    /**
     * 查询信息导入记录列表
     */
    @PreAuthorize("@ss.hasPermi('information:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(InformationImportRecord informationImportRecord) {
        SysUser sysUser = new SysUser();
        List<SysUser> users = userService.selectUserList(sysUser);
        List<Long> userList = users.stream().map(sysUser1 -> sysUser1.getUserId()).collect(Collectors.toList());
        startPage();
        List<InformationImportRecordVO> list = informationImportRecordService.selectInformationImportRecordListByAuth(informationImportRecord,userList);
        return getDataTable(list);
    }
}
